package com.yxinsur.imc.business.mapper;

import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxinsur.imc.business.domain.ImcBroker;
import com.yxinsur.imc.business.fact.TeamBrokerInfo;
import com.yxinsur.imc.business.form.BrokerDimissionSearchForm;
import com.yxinsur.imc.business.form.BrokerSearchForm;
import com.yxinsur.imc.business.vo.BrokerLeaveVo;
import com.yxinsur.imc.business.vo.BrokerVo;
import com.yxinsur.imc.business.vo.CommDetailsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 代理人信息Mapper接口
 *
 * @author imc
 * @date 2021-03-18
 */
@Mapper
public interface ImcBrokerMapper extends BaseMapper<ImcBroker> {
    /**
     * 查询代理人信息
     *
     * @param id 代理人信息ID
     * @return 代理人信息
     */
    public ImcBroker selectImcBrokerById(String id);

    /**
     * 查询代理人信息列表
     *
     * @param imcBroker 代理人信息
     * @return 代理人信息集合
     */
    public List<ImcBroker> selectImcBrokerList(BrokerSearchForm imcBroker);

    /**
     * 新增代理人信息
     *
     * @param imcBroker 代理人信息
     * @return 结果
     */
    public int insertImcBroker(ImcBroker imcBroker);

    /**
     * 修改代理人信息
     *
     * @param imcBroker 代理人信息
     * @return 结果
     */
    public int updateImcBroker(ImcBroker imcBroker);


    int updateImcBrokerLose(@Param("ids") Long[] ids);

    ImcBroker selectImcBrokerByCode(@Param("brokerCode") String brokerCode, @Param("tenantId") Long tenantId);

    List<TeamBrokerInfo> selectBrokerIdsByTeamId(@Param("teamId") Long teamId, @Param("tenantId") Long tenantId);

    /**
     * 查询代理人基本信息+职级+推荐关系
     *
     * @param broker
     * @return
     */
    ArrayList<BrokerVo> selectImcBrokerBaseInfo(BrokerSearchForm broker);

    /**
     * 查询代理人基本信息+职级+推荐关系  基本法包含历史职级
     * @param broker
     * @return
     */
    BrokerVo selectBasicImcBrokerBaseInfo(BrokerSearchForm broker);

    /**
     * 查询团队下的代理人
     *
     * @param teamArr
     * @return
     */
    List<Long> selectBrokerIdsByTeamIds(@Param("teamArr") Long[] teamArr, @Param("tenantId") Long tenantId);

    /**
     * 查询佣金结算代理人基本信息相关
     * @param brokerId
     * @return
     */
    CommDetailsVo selectCommDetailsBroker(Long brokerId);

    List<BrokerLeaveVo> selectBrokerDimissionList(@Param("brokerForm") BrokerDimissionSearchForm brokerForm, @Param("orgIds") List<Long> orgIds, @Param("tenantId") Long tenantId);

    String getMaxBrokerCode(Long tenantId);

    List<ImcBroker> selectImcBrokerByCertiCode(@Param("certiCode") String certiCode, @Param("tenantId") Long tenantId);

    List<BrokerVo> getBrokerVoByCriteria(@Param("criteriaSQL") String criteriaSQL, @Param("tenantId") Long tenantId);

    List<BrokerVo> selectBrokerInfoToCommDetail(@Param("brokerIds") List<Long> brokerIds);

    List<ImcBroker> getImcBrokerByCriteria(@Param("criteriaSQL") String criteriaSQL, @Param("tenantId") Long tenantId);
}
